package utils

import (
	"log"

	"github.com/spf13/viper"
)

func ConfigInit() {
	viper.SetConfigFile("./config/conf.yaml")
	if err := viper.ReadInConfig(); err != nil {
		log.Println("读取配置文件错误！" + err.Error())
	}
	Mysqldns = viper.GetString("mysql.root") + ":" +
		viper.GetString("mysql.passwd") +
		"@tcp(" + viper.GetString("mysql.addr") +
		")/" + viper.GetString("mysql.databases") +
		viper.GetString("mysql.default")
	//fmt.Println(mysqldns)
	Redisaddr = viper.GetString("redis.addr")
	Redispasswd = viper.GetString("redis.passwd")
	RedisDB = viper.GetInt("redis.DB")
	Kafkaaddr = viper.GetString("kafka.addr")
	Kafkatopic = viper.GetString("kafka.topic")
	Kafkacomsumer = viper.GetString("kafka.Attendance_group")
	Kafkacomsumer = viper.GetString("kafka.Attendance_group")
	Kafkapartition = viper.GetInt32("kafka.partition")
	Kafkakey = viper.GetString("kafka.key")

}

var (
	Mysqldns       string //mysql连接数据
	Redisaddr      string //redisIP
	Redispasswd    string //redis密码
	RedisDB        int    //redis数据库分区
	Kafkaaddr      string //kafkaIP
	Kafkatopic     string //kafka主题
	Kafkacomsumer  string //kafka消费组ID
	Kafkapartition int32  //kafka选择消费分区
	Kafkakey       string //kafka考勤签到key值
)
